﻿--HEADER Add [TradeValidationData]

CREATE TABLE [TradingData].[TradeValidationData]
(
	[TradeId] INT NOT NULL PRIMARY KEY,
	[PriceChecked] BIT NOT NULL DEFAULT 0, 
    CONSTRAINT [FK_TradeValidationData_ToTrade] FOREIGN KEY ([TradeId]) REFERENCES [TradingData].[Trade]([Id])
)

GO

--Insert DefaultData

INSERT into [TradingData].TradeValidationData (TradeId)
	select trade.Id from [TradingData].Trade as trade 
	left join [TradingData].TradeValidationData valid on valid.TradeId = trade.Id
	where valid.TradeId is null